package priv.yiyuan.example.design.chain;

/**
 * @author YiYuan
 * @data 2025/10/14
 * @apoNote
 */
public abstract class AbstractDataHandler {

    public final void handle(RawData data) {

        if (!data.isValid()) {
            System.out.println("数据无效, 跳过当前处理步骤。");
            return;
        }

        System.out.println("开始处理: " + this.getClass().getSimpleName());
        preProcess(data);
        doProcess(data);
        postProcess(data);
        System.out.println("完成处理: " + this.getClass().getSimpleName());

    }

    protected void preProcess(RawData data) {

    }

    protected abstract void doProcess(RawData data);

    protected void postProcess(RawData data) {

    }

}
